﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using GeneralLibs;

namespace BI
{
    public partial class BIMainForm : Form
    {
        string _UCDisPlay = "";

        public BIMainForm(string ucWantDisplay)
        {
            InitializeComponent();
            _UCDisPlay = ucWantDisplay;
        }


        private void BIMainForm_Load(object sender, EventArgs e)
        {
            try
            {
                if (DesignMode) return;
                ucBienDongTienMat.TinhChatTaiKhoanMacDinh = "TienMat";
                ucBienDongHangHoa.TinhChatTaiKhoanMacDinh = "GiaMuaHangHoa";
                ucBienDongNoPhaiThu.TinhChatTaiKhoanMacDinh = "PhaiThuKhachHang";

                ucCongNoPhaiThu.TinhChatTaiKhoanMacDinh = "PhaiThuKhachHang";
                ucCongNoPhaiTra.TinhChatTaiKhoanMacDinh = "PhaiTraNhaCungCap";

                ucBienDongTienMat.Title = "Biến động tiền mặt";
                ucBienDongHangHoa.Title = "Biến động giá trị hàng trong kho";
                ucBienDongNoPhaiThu.Title = "Biến động phải thu khách hàng";

                ucCongNoPhaiThu.Title = "Phải thu khách hàng";
                ucCongNoPhaiTra.Title = "Phải trả người bán";

                Control focused = null;
                switch (_UCDisPlay)
                {
                    case "ucDashBoardDetail":
                        if(ucDashBoardDetail == null)
                            ucDashBoardDetail = new UcDashBoardDetail();
                         focused = ucDashBoardDetail;
                         this.WindowState = FormWindowState.Normal;
                        break;
                    case "ucCongNo":
                        focused = ucCongNoPhaiThu;
                         this.WindowState = FormWindowState.Maximized;
                        break;
                   default:
                        break;
                }
                foreach (Control ctrl in panelControlRight.Controls)
                {
                    if (ctrl != focused) ctrl.Dock = DockStyle.None;
                    else
                    {
                        ctrl.Dock = DockStyle.Fill;
                        ctrl.BringToFront();
                    }
                }
            }
            catch (Exception ex)
            {
                BasicForms.FrmExceptionNotifier.ShowAndLog(ex);
            }
        }

        public void SuDungMauBICu()
        {
            ucDashBoard.BringToFront();
            ucDashBoard.Dock = DockStyle.Fill;
        }

        public void SuDungMauBIMoi()
        {
            switch (_UCDisPlay)
            {
                case "ucDashBoardDetail":
                    ucDashBoardDetail.BringToFront();
                    ucDashBoardDetail.Dock = DockStyle.Fill;
                    break;
                default:
                    break;
            }
        }
    }
}
